package com.fire.market.controller;

import com.fire.component.dto.SingleResponse;
import com.fire.component.extension.Assert;

import com.fire.market.product.api.dto.ItemInfo;
import com.fire.market.product.api.request.ItemAddParam;
import com.fire.market.product.api.service.ItemCmdFrontService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ProductCmdController
 *
 * @author zwd
 * @date 2021/7/21
 */
@Slf4j
@RestController
@RequestMapping("product/cmd")
@Api(tags = "商品的cmd操作")
public class ProductCmdController {
    @Reference
    ItemCmdFrontService itemCmdFrontService;

    @PostMapping(value = "addItem")
    @ApiOperation(value = "添加商品", notes = "添加商品")
    public SingleResponse<ItemInfo> addItem(@RequestBody ItemAddParam param){
        Assert.notNull(param, "ItemInfo is null");
        return SingleResponse.of(itemCmdFrontService.addItem(param).getData());
    }
}
